<template>
  <hsa-dialog v-model:visible="dialogVisible" title="权限分析" width="500">
    <el-form :model="formData" label-width="120px">
      <el-form-item label="策略名称">
        <el-input v-model="formData.strategyName"></el-input>
      </el-form-item>
      <el-form-item label="数据库">
        <el-select v-model="formData.database" placeholder="请选择">
          <!-- 这里可以根据实际情况绑定动态选项 -->
          <el-option label="选项1" value="option1"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="数据表">
        <el-select v-model="formData.dataTable" placeholder="请选择">
          <el-option label="选项1" value="option1"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="数据集缓存策略">
        <el-input type="textarea" v-model="formData.cacheStrategy"></el-input>
      </el-form-item>
      <el-form-item label="数据集缓存期限">
        <el-select v-model="formData.cacheDuration" placeholder="请选择">
          <el-option :label="item.label" :value="item.value" :key="item in cacheDurationOptions"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="查询脚本及结果缓存配置">
        <el-input
          type="textarea"
          v-model="formData.queryCacheConfig"
        ></el-input>
      </el-form-item>
      <el-form-item label="脚本key">
        <el-input v-model="formData.scriptKey"></el-input>
      </el-form-item>
      <el-form-item label="维值信息配置">
        <el-input
          type="textarea"
          v-model="formData.dimensionValueConfig"
        ></el-input>
      </el-form-item>
      <el-form-item label="维值取值调度">
        <el-time-picker
          v-model="formData.scheduling"
          placeholder=""
          style="width: 200px"
        /><span class="input-info">开始进行周期调度</span>
      </el-form-item>
      <el-form-item label="取值逻辑处理">
        <el-select v-model="formData.valueLogic" placeholder="请选择">
          <el-option :label="item.label" :value="item.value" v-for="item in valueLogicOptions" :key="item.value"></el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="handleSubmit">保存</el-button>
      </span>
    </template>
  </hsa-dialog>
</template>

<script setup>
import { ref } from "vue";
import { ElMessage } from "element-plus";

// 控制弹窗显示隐藏
const dialogVisible = ref(false);
// 表单数据
const formData = ref({
  strategyName: "",
  database: "",
  dataTable: "",
  cacheStrategy: "",
  cacheDuration: "",
  queryCacheConfig: "",
  scriptKey: "",
  dimensionValueConfig: "",
  valueLogic: "",
  scheduling: "",
});
const valueLogicOptions=[
  {value:"dimensionValue",label:"优先维值"},
  {value:"formFeild",label:"优先表字段"},
]
const cacheDurationOptions=[
{value:"7",label:"7天"},
{value:"15",label:"15天"},
{value:"30",label:"30天"},
{value:"60",label:"60天"},
{value:"90",label:"90天"},

]
// 关闭弹窗前的处理函数
const handleBeforeClose = () => {
  // 可添加关闭前确认逻辑，如提示未保存数据等
};

// 提交表单处理函数
const handleSubmit = () => {
  // 这里可以添加提交表单后的业务逻辑，如发送请求保存配置
  ElMessage.success("保存成功");
  dialogVisible.value = false;
};

// 对外暴露打开弹窗的方法
const open = () => {
  dialogVisible.value = true;
};

// 导出方法，方便外部调用打开弹窗
defineExpose({
  open,
});
</script>

<style scoped>
.dialog-footer {
  display: flex;
  justify-content: flex-end;
}
.input-info {
  font-size: 12px;
  margin-left: 12px;
}
</style>
